/*
 * Node.h
 *
 *  Created on: 18/09/2011
 *      Author: godinho
 */

#ifndef NODE_H_
#define NODE_H_

#include <localview/Street.h>
#include <vector>

class Node;

class Phase;

class Node {

public:

	/**
	 * Constructor
	 */
	Node(std::string nodeId);

	/**
	 * Desctructor
	 */
	virtual ~Node();

	/**
	 * Add a street controled by this node.
	 */
	void addStreet(Street* street);

	/**
	 * Add a neighbor to this node.
	 */
	void addNeighbor(Node* node, int direction);

	/**
	 * Return street by its name.
	 *
	 * If no street match with the name passed, this method return 0
	 */
	Street* getStreetByName(std::string streetName);

	/**
	 * Returns node id.
	 *
	 * A string that identifies the node on network
	 */
	std::string getNodeId();

	/**
	 * Get address used to comunicate with this node of TLS network
	 * TODO define this address format
	 *
	 * @return tls address on tls network
	 */
	std::string getAddress();

	/**
	 * Set address used to comunicate with this node on TLS network.
	 * TODO define this address format
	 */
	void setAddress(std::string address);

	/**
	 * Add a new phase for this node.
	 *
	 * @see Phase
	 *
	 * @param phase Object that defines a traffic light phase.
	 */
	void addPhase(Phase* phase);

	/**
	 * Return number of phases on this traffic light controler.
	 *
	 * @return number of phases
	 */
	int getPhaseCount();

	/**
	 * Get the nth phase on this node.
	 *
	 * @param n Index of phase
	 * @return object that holds phase definition.
	 */
	Phase* getPhase(int n);

	int getX();

	void setX(int x);

	int getY();

	void setY(int y);

	void setTraversalStatus(int s);

	int getTraversalStatus();

	std::vector<Node*> getNeighbors();

	std::vector<Phase*> getPhases();

/*
 * Local view
 */
private:

	std::string mId;

	std::vector<Street*> mStreets;

	std::vector<Node*> mNeighbors;

	std::string mAddress;

	std::vector<Phase*> mPhases;

	int mX;

	int mY;

	int mTraversalStatus;
};

#endif /* NODE_H_ */
